<?php

namespace JLPay\Models\Trans\Union;

use JLPay\Models\BaseRequest;

/**
 * 银联JS支付请求模型
 */
class UnionJsPayRequest extends BaseRequest
{
    /**
     * @var string|null 商户号
     */
    private ?string $mchId = null;

    /**
     * @var string|null 终端号
     */
    private ?string $termNo = null;

    /**
     * @var string|null 交易类型
     */
    private ?string $payType = null;

    /**
     * @var string|null 银联支付标识
     */
    private ?string $appUpIdentifier = null;

    /**
     * @var string|null 用户授权码
     */
    private ?string $userAuthCode = null;

    /**
     * @var string|null 用户标识
     */
    private ?string $userId = null;

    /**
     * @var string|null 商户订单号
     */
    private ?string $outTradeNo = null;

    /**
     * @var string|null 订单有效期
     */
    private ?string $paymentValidTime = null;

    /**
     * @var string|null 商品标题
     */
    private ?string $body = null;

    /**
     * @var string|null 商品描述
     */
    private ?string $attach = null;

    /**
     * @var string|null 交易金额
     */
    private ?string $totalFee = null;

    /**
     * @var string|null 备注
     */
    private ?string $remark = null;

    /**
     * @var string|null 回调地址
     */
    private ?string $notifyUrl = null;

    /**
     * @var string|null 操作员
     */
    private ?string $opUserId = null;

    /**
     * @var string|null 门店号
     */
    private ?string $opShopId = null;

    /**
     * @var string|null 终端设备号
     */
    private ?string $deviceInfo = null;

    /**
     * @var string|null 终端IP
     */
    private ?string $mchCreateIp = null;

    /**
     * @var string|null 经度
     */
    private ?string $longitude = null;

    /**
     * @var string|null 纬度
     */
    private ?string $latitude = null;

    /**
     * @var string|null 支付成功跳转
     */
    private ?string $frontUrl = null;

    /**
     * @var string|null 支付失败跳转
     */
    private ?string $frontFailUrl = null;

    /**
     * @var string|null 二维码地址
     */
    private ?string $qrCode = null;

    /**
     * @var mixed|null 终端信息
     */
    private $terminalInfo = null;

    /**
     * 获取API路径
     *
     * @return string API路径
     */
    public function getApiPath(): string
    {
        return '/open/trans/unionjspay';
    }

    /**
     * 设置商户号
     *
     * @param string $mchId 商户号
     * @return $this
     */
    public function setMchId(string $mchId): self
    {
        $this->mchId = $mchId;
        return $this;
    }

    /**
     * 获取商户号
     *
     * @return string|null 商户号
     */
    public function getMchId(): ?string
    {
        return $this->mchId;
    }

    /**
     * 设置终端号
     *
     * @param string $termNo 终端号
     * @return $this
     */
    public function setTermNo(string $termNo): self
    {
        $this->termNo = $termNo;
        return $this;
    }

    /**
     * 获取终端号
     *
     * @return string|null 终端号
     */
    public function getTermNo(): ?string
    {
        return $this->termNo;
    }

    /**
     * 设置交易类型
     *
     * @param string $payType 交易类型
     * @return $this
     */
    public function setPayType(string $payType): self
    {
        $this->payType = $payType;
        return $this;
    }

    /**
     * 获取交易类型
     *
     * @return string|null 交易类型
     */
    public function getPayType(): ?string
    {
        return $this->payType;
    }

    /**
     * 设置银联支付标识
     *
     * @param string $appUpIdentifier 银联支付标识
     * @return $this
     */
    public function setAppUpIdentifier(string $appUpIdentifier): self
    {
        $this->appUpIdentifier = $appUpIdentifier;
        return $this;
    }

    /**
     * 获取银联支付标识
     *
     * @return string|null 银联支付标识
     */
    public function getAppUpIdentifier(): ?string
    {
        return $this->appUpIdentifier;
    }

    /**
     * 设置用户授权码
     *
     * @param string $userAuthCode 用户授权码
     * @return $this
     */
    public function setUserAuthCode(string $userAuthCode): self
    {
        $this->userAuthCode = $userAuthCode;
        return $this;
    }

    /**
     * 获取用户授权码
     *
     * @return string|null 用户授权码
     */
    public function getUserAuthCode(): ?string
    {
        return $this->userAuthCode;
    }

    /**
     * 设置用户标识
     *
     * @param string $userId 用户标识
     * @return $this
     */
    public function setUserId(string $userId): self
    {
        $this->userId = $userId;
        return $this;
    }

    /**
     * 获取用户标识
     *
     * @return string|null 用户标识
     */
    public function getUserId(): ?string
    {
        return $this->userId;
    }

    /**
     * 设置商户订单号
     *
     * @param string $outTradeNo 商户订单号
     * @return $this
     */
    public function setOutTradeNo(string $outTradeNo): self
    {
        $this->outTradeNo = $outTradeNo;
        return $this;
    }

    /**
     * 获取商户订单号
     *
     * @return string|null 商户订单号
     */
    public function getOutTradeNo(): ?string
    {
        return $this->outTradeNo;
    }

    /**
     * 设置订单有效期
     *
     * @param string $paymentValidTime 订单有效期
     * @return $this
     */
    public function setPaymentValidTime(string $paymentValidTime): self
    {
        $this->paymentValidTime = $paymentValidTime;
        return $this;
    }

    /**
     * 获取订单有效期
     *
     * @return string|null 订单有效期
     */
    public function getPaymentValidTime(): ?string
    {
        return $this->paymentValidTime;
    }

    /**
     * 设置商品标题
     *
     * @param string $body 商品标题
     * @return $this
     */
    public function setBody(string $body): self
    {
        $this->body = $body;
        return $this;
    }

    /**
     * 获取商品标题
     *
     * @return string|null 商品标题
     */
    public function getBody(): ?string
    {
        return $this->body;
    }

    /**
     * 设置商品描述
     *
     * @param string $attach 商品描述
     * @return $this
     */
    public function setAttach(string $attach): self
    {
        $this->attach = $attach;
        return $this;
    }

    /**
     * 获取商品描述
     *
     * @return string|null 商品描述
     */
    public function getAttach(): ?string
    {
        return $this->attach;
    }

    /**
     * 设置交易金额
     *
     * @param string $totalFee 交易金额
     * @return $this
     */
    public function setTotalFee(string $totalFee): self
    {
        $this->totalFee = $totalFee;
        return $this;
    }

    /**
     * 获取交易金额
     *
     * @return string|null 交易金额
     */
    public function getTotalFee(): ?string
    {
        return $this->totalFee;
    }

    /**
     * 设置备注
     *
     * @param string $remark 备注
     * @return $this
     */
    public function setRemark(string $remark): self
    {
        $this->remark = $remark;
        return $this;
    }

    /**
     * 获取备注
     *
     * @return string|null 备注
     */
    public function getRemark(): ?string
    {
        return $this->remark;
    }

    /**
     * 设置回调地址
     *
     * @param string $notifyUrl 回调地址
     * @return $this
     */
    public function setNotifyUrl(string $notifyUrl): self
    {
        $this->notifyUrl = $notifyUrl;
        return $this;
    }

    /**
     * 获取回调地址
     *
     * @return string|null 回调地址
     */
    public function getNotifyUrl(): ?string
    {
        return $this->notifyUrl;
    }

    /**
     * 设置操作员
     *
     * @param string $opUserId 操作员
     * @return $this
     */
    public function setOpUserId(string $opUserId): self
    {
        $this->opUserId = $opUserId;
        return $this;
    }

    /**
     * 获取操作员
     *
     * @return string|null 操作员
     */
    public function getOpUserId(): ?string
    {
        return $this->opUserId;
    }

    /**
     * 设置门店号
     *
     * @param string $opShopId 门店号
     * @return $this
     */
    public function setOpShopId(string $opShopId): self
    {
        $this->opShopId = $opShopId;
        return $this;
    }

    /**
     * 获取门店号
     *
     * @return string|null 门店号
     */
    public function getOpShopId(): ?string
    {
        return $this->opShopId;
    }

    /**
     * 设置终端设备号
     *
     * @param string $deviceInfo 终端设备号
     * @return $this
     */
    public function setDeviceInfo(string $deviceInfo): self
    {
        $this->deviceInfo = $deviceInfo;
        return $this;
    }

    /**
     * 获取终端设备号
     *
     * @return string|null 终端设备号
     */
    public function getDeviceInfo(): ?string
    {
        return $this->deviceInfo;
    }

    /**
     * 设置终端IP
     *
     * @param string $mchCreateIp 终端IP
     * @return $this
     */
    public function setMchCreateIp(string $mchCreateIp): self
    {
        $this->mchCreateIp = $mchCreateIp;
        return $this;
    }

    /**
     * 获取终端IP
     *
     * @return string|null 终端IP
     */
    public function getMchCreateIp(): ?string
    {
        return $this->mchCreateIp;
    }

    /**
     * 设置经度
     *
     * @param string $longitude 经度
     * @return $this
     */
    public function setLongitude(string $longitude): self
    {
        $this->longitude = $longitude;
        return $this;
    }

    /**
     * 获取经度
     *
     * @return string|null 经度
     */
    public function getLongitude(): ?string
    {
        return $this->longitude;
    }

    /**
     * 设置纬度
     *
     * @param string $latitude 纬度
     * @return $this
     */
    public function setLatitude(string $latitude): self
    {
        $this->latitude = $latitude;
        return $this;
    }

    /**
     * 获取纬度
     *
     * @return string|null 纬度
     */
    public function getLatitude(): ?string
    {
        return $this->latitude;
    }

    /**
     * 设置支付成功跳转
     *
     * @param string $frontUrl 支付成功跳转
     * @return $this
     */
    public function setFrontUrl(string $frontUrl): self
    {
        $this->frontUrl = $frontUrl;
        return $this;
    }

    /**
     * 获取支付成功跳转
     *
     * @return string|null 支付成功跳转
     */
    public function getFrontUrl(): ?string
    {
        return $this->frontUrl;
    }

    /**
     * 设置支付失败跳转
     *
     * @param string $frontFailUrl 支付失败跳转
     * @return $this
     */
    public function setFrontFailUrl(string $frontFailUrl): self
    {
        $this->frontFailUrl = $frontFailUrl;
        return $this;
    }

    /**
     * 获取支付失败跳转
     *
     * @return string|null 支付失败跳转
     */
    public function getFrontFailUrl(): ?string
    {
        return $this->frontFailUrl;
    }

    /**
     * 设置二维码地址
     *
     * @param string $qrCode 二维码地址
     * @return $this
     */
    public function setQrCode(string $qrCode): self
    {
        $this->qrCode = $qrCode;
        return $this;
    }

    /**
     * 获取二维码地址
     *
     * @return string|null 二维码地址
     */
    public function getQrCode(): ?string
    {
        return $this->qrCode;
    }

    /**
     * 设置终端信息
     *
     * @param mixed $terminalInfo 终端信息
     * @return $this
     */
    public function setTerminalInfo($terminalInfo): self
    {
        $this->terminalInfo = $terminalInfo;
        return $this;
    }

    /**
     * 获取终端信息
     *
     * @return mixed|null 终端信息
     */
    public function getTerminalInfo()
    {
        return $this->terminalInfo;
    }

    /**
     * 转换为数组格式
     *
     * @return array 数组格式的数据
     */
    public function toArray(): array
    {
        $data = parent::toArray();
        $data = array_merge($data, [
            'mch_id' => $this->mchId,
            'term_no' => $this->termNo,
            'pay_type' => $this->payType,
            'app_up_identifier' => $this->appUpIdentifier,
            'user_auth_code' => $this->userAuthCode,
            'user_id' => $this->userId,
            'out_trade_no' => $this->outTradeNo,
            'payment_valid_time' => $this->paymentValidTime,
            'body' => $this->body,
            'attach' => $this->attach,
            'total_fee' => $this->totalFee,
            'remark' => $this->remark,
            'notify_url' => $this->notifyUrl,
            'op_user_id' => $this->opUserId,
            'op_shop_id' => $this->opShopId,
            'device_info' => $this->deviceInfo,
            'mch_create_ip' => $this->mchCreateIp,
            'longitude' => $this->longitude,
            'latitude' => $this->latitude,
            'front_url' => $this->frontUrl,
            'front_fail_url' => $this->frontFailUrl,
            'qr_code' => $this->qrCode,
            'terminal_info' => $this->terminalInfo
        ]);

        return $data;
    }
} 